package com.ap.core.validation.message.rules;

import com.ap.core.dao.RefundReasonDao;
import com.ap.core.domain.RefundReason;
import com.ap.core.message.managerefund.info.RequestRetrieveRefundAccountInfo;
import com.ap.core.validation.message.info.MessageValidationInfo;
import com.ap.core.validation.message.info.OriginalInfo;
import com.ap.core.validation.rules.AbstractValidationRule;

/**
 * User: Gibu.Paul 
 * The RefundReason does not match a value in Database
 */

public class RV0017Rule
		extends
		AbstractValidationRule<MessageValidationInfo<RequestRetrieveRefundAccountInfo, OriginalInfo>> {

	private RefundReasonDao refundReasonDao;

	@Override
	public boolean validate(
			MessageValidationInfo<RequestRetrieveRefundAccountInfo, OriginalInfo> infoObject) {
		String refundReasonCode = null;

		refundReasonCode = infoObject
				.getBoundObject().getRefundRequestInfo().getRefundReasonType();

		final RefundReason refundReason = refundReasonDao
				.findById(refundReasonCode);
		return null != refundReason;
	}

	public void setrefundReasonDao(RefundReasonDao refundReasonDao) {
		this.refundReasonDao = refundReasonDao;
	}

}